/**
  Global types definitation 
**/

enum CourtType_t {
  Badminton,
  TableTennis
};

enum ReturnType_t {
	OK_BOOK_COURT_SYS,
	BAD_SERVER_BUSY,
	BAD_TIME_SLOT_OCCUPIED,
	BAD_DUPLICATED_BOOKING,
	BAD_TECHNICAL_PROBLEM,
	BAD_EXPECTED_WRITE_SET_ID,
	BAD_SESSION_NOT_OPENED,
	BAD_SESSION_ACCESS_DENIED,
	BAD_SESSION_NOT_FOUND,
	BAD_LAST_SESSION_TIME_OUT,
	BAD_TICKET_NO_NOT_FOUND,
	BAD_MESSAGE_LOG_NOT_FOUND
};

struct ReturnStatus_t {
  ReturnType_t returnType;
  string statusMessage<>;
};

struct TimeSlot_t {
  int tm_hour;    /* hours since midnight - [0,23] */
  int tm_mday;    /* day of the month - [1,31] */
  int tm_mon;     /* months since January - [0,11] */
  int tm_year;    /* years since 1900 */
};

/**
  Types definitation for each method
**/

struct BookCourtArgs_t {
  int studentId;
  longlong_t lastStudentWriteSetId;
  longlong_t nextStudentWriteSetId;
  string studentName<>;
  TimeSlot_t timeSlotStart;
  int numHours;
  CourtType_t courtType;
};

struct BookCourtRet_t {
  int bookTicketNo;
  longlong_t nextStduentWriteSetId;
  ReturnStatus_t returnStatus;
};

struct CancelCourtArgs_t {
  int studentId;
  longlong_t lastStudentWriteSetId;
  longlong_t nextStudentWriteSetId;
  int bookTicketNo;
};

struct CancelCourtRet_t {
  longlong_t nextStudentWriteSetId;
  ReturnStatus_t returnStatus;
};

struct ViewTimeSlotArgs_t {
  int studentId;
  longlong_t lastStudentWriteSetId;
  CourtType_t courtType;
  TimeSlot_t startTimeSlot;
  int numHours;
};

struct ViewTimeSlotRet_t {
  int vectorBookTicketNo<>;
  ReturnStatus_t returnStatus;
};

struct ViewBookTicketNoArgs_t {
  int studentId;
  longlong_t lastStudentWriteSetId;
  int bookTicketNo;
};

struct ViewBookTicketNoRet_t {
  int studentId;
  string studentName<>;
  CourtType_t courtType;
  TimeSlot_t timeSlotStart;
  int numHours;
  ReturnStatus_t returnStatus;
};

struct ViewStudentArgs_t {
  int studentId;
  longlong_t lastStudentWriteSetId;
};

struct ViewStudentRet_t {
  int vectorBookTicketNo<>;
  ReturnStatus_t returnStatus;
};

program BOOKCOURTSYS {
  version MSGVER {
    ReturnStatus_t OpenSession (int) = 1;
    ReturnStatus_t CloseSession (int) = 2;
    BookCourtRet_t BookCourt (BookCourtArgs_t) = 3;
    CancelCourtRet_t CancelCourt (CancelCourtArgs_t) = 4;
    ViewTimeSlotRet_t ViewTimeSlot (ViewTimeSlotArgs_t) = 5;
    ViewBookTicketNoRet_t ViewBookTicketNo (ViewBookTicketNoArgs_t) = 6;
    ViewStudentRet_t ViewStudent (ViewStudentArgs_t) = 7;
  } = 1;
} = 50419704;